<?php
// +----------------------------------------------------------------------
// | ManniuRead
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2016 http://manniuyun.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: heitao <read@manniuyun.com>
// +----------------------------------------------------------------------

namespace app\admin\controller;

use manniu\controller\AdminBase;

use think\Db;
use think\Cache;

class Index extends AdminBase{

    /**
     * 后台框架
     * @access public
     * @return \think\Response
     */
    public function index(){
    	// 临时关闭当前模板的布局功能
    	$this->view->engine->layout(false);
    	return $this->fetch();
    }

    /**
     * 后台首页
     * @access public
     * @return \think\Response
     */
    public function main(){
    	if(strtolower(config('database.type')) == 'mysql'){
    		$db_version = Db::query('select version() as version');
    		$db_version = $db_version[0]['version'];
    	}
    	$db_version = $db_version ? $db_version : '未知数据库';
    	$this->assign([
    		'db_version' => $db_version
    	]);
    	return $this->fetch();
    }

    /**
     * 更新全站缓存
     * @access public
     * @return void
     */
    public function cache(){
        Cache::clear();
        return $this->fetch();
    }
}
